package com.wpw.dream.thread;

public class RunThread extends Thread {

	private boolean  running = true;

	@Override
	public void run() {
		while (running == true) {
			//System.out.println(running);
			//System.out.print("--");
			synchronized (RunThread.class) {
				
				boolean running2 = getRunning();
				int i = 0;
			}
			
		}
		System.out.println("线程停止");
	}
	
	public void setRunning (boolean running) {
		this.running = running;
	}
	
	public boolean getRunning() {
		return this.running;
	}
	
	public static void main(String[] args) throws InterruptedException {
		RunThread t = new RunThread();
		t.start();
		Thread.sleep(1000);
		t.setRunning(false);
		System.out.println("running被设置成false");
		Thread.sleep(1000);
		System.out.println("主线程中running：" + t.getRunning());
		
		
		
	}
	
}
